{% extends "news_layout.html" %}

{% block others %}
<div class="contact">
  <img src="../public/img/wechat_num.png" alt="">
</div>
{% endblock %}

{% block main %}
<div class="main contact">
  <div class="contact-address border-bottom-line">
    <h2>Contact Us</h2>
    <div id="map"></div>
    <div class="contact-address__wrapper">
      <h3>Address</h3>
      <p>Lushan South Road Yifu Building, Hunan University South Campus, Changsha, Hunan China</p>
      <h3>Contact Information</h3>
      <p>Email: xxx@hnu.edu.cn</p>
      <p>Phone: +86-731-88821894</p>
      <p>Fac: +86-731-88821894</p>
    </div>
  </div>
  <div class="positions-available">
    <h2>Positions Available</h2>
    <p>暂无</p>
  </div>
</div>
{% endblock %}

{% block mapinfo %}
<script type="text/javascript" src="http://api.map.baidu.com/api?v=1.4"></script>
<script type="text/javascript">
  /* eslint-disable */
  //创建和初始化地图函数：
  function initMap(){
    createMap();//创建地图
    setMapEvent();//设置地图事件
    addMapControl();//向地图添加控件
    addMapOverlay();//向地图添加覆盖物
  }
  function createMap(){
    map = new BMap.Map("map");
    map.centerAndZoom(new BMap.Point(112.952295,28.181367),19);
  }
  function setMapEvent(){
    map.enableScrollWheelZoom();
    // map.enableKeyboard();
    map.enableDragging();
  }
  function addClickHandler(target,window){
    target.addEventListener("click",function(){
      target.openInfoWindow(window);
    });
  }
  function addMapOverlay(){
    var markers = [
      {content:"",title:"Here",imageOffset: {width:0,height:3},position:{lat:28.180961,lng:112.95199}}
    ];
    for(var index = 0; index < markers.length; index++ ){
      var point = new BMap.Point(markers[index].position.lng,markers[index].position.lat);
      var marker = new BMap.Marker(point,{icon:new BMap.Icon("http://api.map.baidu.com/lbsapi/createmap/images/icon.png",new BMap.Size(20,25),{
          imageOffset: new BMap.Size(markers[index].imageOffset.width,markers[index].imageOffset.height)
        })});
      var label = new BMap.Label(markers[index].title,{offset: new BMap.Size(25,5)});
      var opts = {
        width: 200,
        title: markers[index].title,
        enableMessage: false
      };
      var infoWindow = new BMap.InfoWindow(markers[index].content,opts);
      marker.setLabel(label);
      addClickHandler(marker,infoWindow);
      map.addOverlay(marker);
    };
    var labels = [
    ];
    for(var index = 0; index < labels.length; index++){
      var opt = { position: new BMap.Point(labels[index].position.lng,labels[index].position.lat )};
      var label = new BMap.Label(labels[index].content,opt);
      map.addOverlay(label);
    };
  }
  //向地图添加控件
  function addMapControl(){
    var navControl = new BMap.NavigationControl({anchor:BMAP_ANCHOR_TOP_LEFT,type:3});
    map.addControl(navControl);
  }
  var map;
  initMap();
</script>
{% endblock %}
